
#include "lcd_internal.h"

#if !MODULE_CHECK_ENABLED( LCD_QSPI )
#error "must define qspi lcd interface!!!"
#endif

GUI_RAM_CODE
bool lcd_write_completed(void)
{
    if( lcd_wrctl.block_write ) 
    {
        if( lcd_wrctl.offset < lcd_wrctl.size )
        {
            uint16_t remain = lcd_wrctl.size - lcd_wrctl.offset;
            if( remain > LCD_XFER_MAX_SIZE )
            {
                remain = LCD_XFER_MAX_SIZE;
            }
            LCD_SEND_DATA_ASYNC( lcd_wrctl.pdata + lcd_wrctl.offset, remain );
            lcd_wrctl.offset += remain;
        }
        else 
        {
            lcd_wrctl.blocks.used ++;
            if( lcd_wrctl.blocks.used < lcd_wrctl.blocks.count )
            {
                // check next row 
                lcd_wrctl.pdata += lcd_wrctl.blocks.offset; // next block  
                lcd_wrctl.offset = 0; 
                uint16_t remain = lcd_wrctl.size;
                if( remain > LCD_XFER_MAX_SIZE )
                {
                    remain = LCD_XFER_MAX_SIZE; 
                }
                
                LCD_SEND_DATA_ASYNC( lcd_wrctl.pdata, remain );
                lcd_wrctl.offset = remain; //start a block 
            }
            else 
            {
                lcd_wrctl.isbusy = false; 
            }
        }
    }
    else 
    {
        if( lcd_wrctl.offset < lcd_wrctl.size )
        {
            uint16_t remain = lcd_wrctl.size - lcd_wrctl.offset;
            if( remain > LCD_XFER_MAX_SIZE )
            {
                remain = LCD_XFER_MAX_SIZE;
            }
            LCD_SEND_DATA_ASYNC( lcd_wrctl.pdata + lcd_wrctl.offset, remain );
            lcd_wrctl.offset += remain;
        }
        else 
        {
            lcd_wrctl.isbusy = false; 
        }
    }
    return lcd_wrctl.isbusy;
}



static void driver_init(void)
{
    LCD_SET_nRESET;
    LCD_DELAY_MS( 10*2 );
    LCD_SET_RESET;
    LCD_DELAY_MS( 20*3 );
    LCD_SET_nRESET;
    LCD_DELAY_MS( 20*3 );

{
  uint8_t data[]={0x20,0x10,0x43};
  lcd_qspi_write_cmd_para(0xff,data,sizeof(data));
}
{
  uint8_t data[]={0x70};
  lcd_qspi_write_cmd_para(0x04,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0x10};
  lcd_qspi_write_cmd_para(0xFF,data,sizeof(data));
}
{
  uint8_t data[]={0x11};
  lcd_qspi_write_cmd_para(0x0C,data,sizeof(data));
}
{
  uint8_t data[]={0x02};
  lcd_qspi_write_cmd_para(0x10,data,sizeof(data));
}
{
  uint8_t data[]={0x11};
  lcd_qspi_write_cmd_para(0x11,data,sizeof(data));
}
{
  uint8_t data[]={0x42};
  lcd_qspi_write_cmd_para(0x15,data,sizeof(data));
}
{
  uint8_t data[]={0x11};
  lcd_qspi_write_cmd_para(0x16,data,sizeof(data));
}
{
  uint8_t data[]={0x02};
  lcd_qspi_write_cmd_para(0x1A,data,sizeof(data));
}
{
  uint8_t data[]={0x11};
  lcd_qspi_write_cmd_para(0x1B,data,sizeof(data));
}
{
  uint8_t data[]={0x80};
  lcd_qspi_write_cmd_para(0x61,data,sizeof(data));
}
{
  uint8_t data[]={0x80};
  lcd_qspi_write_cmd_para(0x62,data,sizeof(data));
}
{
  uint8_t data[]={0x44};
  lcd_qspi_write_cmd_para(0x54,data,sizeof(data));
}
{
  uint8_t data[]={0x88};
  lcd_qspi_write_cmd_para(0x58,data,sizeof(data));
}
{
  uint8_t data[]={0xcc};
  lcd_qspi_write_cmd_para(0x5C,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0x10};
  lcd_qspi_write_cmd_para(0xFF,data,sizeof(data));
}
{
  uint8_t data[]={0x80};
  lcd_qspi_write_cmd_para(0x20,data,sizeof(data));
}
{
  uint8_t data[]={0x81};
  lcd_qspi_write_cmd_para(0x21,data,sizeof(data));
}
{
  uint8_t data[]={0x31};
  lcd_qspi_write_cmd_para(0x22,data,sizeof(data));
}
{
  uint8_t data[]={0x20};
  lcd_qspi_write_cmd_para(0x23,data,sizeof(data));
}
{
  uint8_t data[]={0x11};
  lcd_qspi_write_cmd_para(0x24,data,sizeof(data));
}
{
  uint8_t data[]={0x11};
  lcd_qspi_write_cmd_para(0x25,data,sizeof(data));
}
{
  uint8_t data[]={0x12};
  lcd_qspi_write_cmd_para(0x26,data,sizeof(data));
}
{
  uint8_t data[]={0x12};
  lcd_qspi_write_cmd_para(0x27,data,sizeof(data));
}
{
  uint8_t data[]={0x80};
  lcd_qspi_write_cmd_para(0x30,data,sizeof(data));
}
{
  uint8_t data[]={0x81};
  lcd_qspi_write_cmd_para(0x31,data,sizeof(data));
}
{
  uint8_t data[]={0x31};
  lcd_qspi_write_cmd_para(0x32,data,sizeof(data));
}
{
  uint8_t data[]={0x20};
  lcd_qspi_write_cmd_para(0x33,data,sizeof(data));
}
{
  uint8_t data[]={0x11};
  lcd_qspi_write_cmd_para(0x34,data,sizeof(data));
}
{
  uint8_t data[]={0x11};
  lcd_qspi_write_cmd_para(0x35,data,sizeof(data));
}
{
  uint8_t data[]={0x12};
  lcd_qspi_write_cmd_para(0x36,data,sizeof(data));
}
{
  uint8_t data[]={0x12};
  lcd_qspi_write_cmd_para(0x37,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0x10};
  lcd_qspi_write_cmd_para(0xFF,data,sizeof(data));
}
{
  uint8_t data[]={0x11};
  lcd_qspi_write_cmd_para(0x41,data,sizeof(data));
}
{
  uint8_t data[]={0x22};
  lcd_qspi_write_cmd_para(0x42,data,sizeof(data));
}
{
  uint8_t data[]={0x33};
  lcd_qspi_write_cmd_para(0x43,data,sizeof(data));
}
{
  uint8_t data[]={0x11};
  lcd_qspi_write_cmd_para(0x49,data,sizeof(data));
}
{
  uint8_t data[]={0x22};
  lcd_qspi_write_cmd_para(0x4A,data,sizeof(data));
}
{
  uint8_t data[]={0x33};
  lcd_qspi_write_cmd_para(0x4B,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0x15};
  lcd_qspi_write_cmd_para(0xFF,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x00,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x01,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x02,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x03,data,sizeof(data));
}
{
  uint8_t data[]={0x10};
  lcd_qspi_write_cmd_para(0x04,data,sizeof(data));
}
{
  uint8_t data[]={0x0C};
  lcd_qspi_write_cmd_para(0x05,data,sizeof(data));
}
{
  uint8_t data[]={0x23};
  lcd_qspi_write_cmd_para(0x06,data,sizeof(data));
}
{
  uint8_t data[]={0x22};
  lcd_qspi_write_cmd_para(0x07,data,sizeof(data));
}
{
  uint8_t data[]={0x21};
  lcd_qspi_write_cmd_para(0x08,data,sizeof(data));
}
{
  uint8_t data[]={0x20};
  lcd_qspi_write_cmd_para(0x09,data,sizeof(data));
}
{
  uint8_t data[]={0x33};
  lcd_qspi_write_cmd_para(0x0A,data,sizeof(data));
}
{
  uint8_t data[]={0x32};
  lcd_qspi_write_cmd_para(0x0B,data,sizeof(data));
}
{
  uint8_t data[]={0x34};
  lcd_qspi_write_cmd_para(0x0C,data,sizeof(data));
}
{
  uint8_t data[]={0x35};
  lcd_qspi_write_cmd_para(0x0D,data,sizeof(data));
}
{
  uint8_t data[]={0x01};
  lcd_qspi_write_cmd_para(0x0E,data,sizeof(data));
}
{
  uint8_t data[]={0x01};
  lcd_qspi_write_cmd_para(0x0F,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x20,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x21,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x22,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x23,data,sizeof(data));
}
{
  uint8_t data[]={0x0C};
  lcd_qspi_write_cmd_para(0x24,data,sizeof(data));
}
{
  uint8_t data[]={0x10};
  lcd_qspi_write_cmd_para(0x25,data,sizeof(data));
}
{
  uint8_t data[]={0x20};
  lcd_qspi_write_cmd_para(0x26,data,sizeof(data));
}
{
  uint8_t data[]={0x21};
  lcd_qspi_write_cmd_para(0x27,data,sizeof(data));
}
{
  uint8_t data[]={0x22};
  lcd_qspi_write_cmd_para(0x28,data,sizeof(data));
}
{
  uint8_t data[]={0x23};
  lcd_qspi_write_cmd_para(0x29,data,sizeof(data));
}
{
  uint8_t data[]={0x33};
  lcd_qspi_write_cmd_para(0x2A,data,sizeof(data));
}
{
  uint8_t data[]={0x32};
  lcd_qspi_write_cmd_para(0x2B,data,sizeof(data));
}
{
  uint8_t data[]={0x34};
  lcd_qspi_write_cmd_para(0x2C,data,sizeof(data));
}
{
  uint8_t data[]={0x35};
  lcd_qspi_write_cmd_para(0x2D,data,sizeof(data));
}
{
  uint8_t data[]={0x01};
  lcd_qspi_write_cmd_para(0x2E,data,sizeof(data));
}
{
  uint8_t data[]={0x01};
  lcd_qspi_write_cmd_para(0x2F,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0x16};
  lcd_qspi_write_cmd_para(0xFF,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x00,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x01,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x02,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x03,data,sizeof(data));
}
{
  uint8_t data[]={0x08};
  lcd_qspi_write_cmd_para(0x04,data,sizeof(data));
}
{
  uint8_t data[]={0x04};
  lcd_qspi_write_cmd_para(0x05,data,sizeof(data));
}
{
  uint8_t data[]={0x19};
  lcd_qspi_write_cmd_para(0x06,data,sizeof(data));
}
{
  uint8_t data[]={0x18};
  lcd_qspi_write_cmd_para(0x07,data,sizeof(data));
}
{
  uint8_t data[]={0x17};
  lcd_qspi_write_cmd_para(0x08,data,sizeof(data));
}
{
  uint8_t data[]={0x16};
  lcd_qspi_write_cmd_para(0x09,data,sizeof(data));
}
{
  uint8_t data[]={0x33};
  lcd_qspi_write_cmd_para(0x0A,data,sizeof(data));
}
{
  uint8_t data[]={0x32};
  lcd_qspi_write_cmd_para(0x0B,data,sizeof(data));
}
{
  uint8_t data[]={0x34};
  lcd_qspi_write_cmd_para(0x0C,data,sizeof(data));
}
{
  uint8_t data[]={0x35};
  lcd_qspi_write_cmd_para(0x0D,data,sizeof(data));
}
{
  uint8_t data[]={0x01};
  lcd_qspi_write_cmd_para(0x0E,data,sizeof(data));
}
{
  uint8_t data[]={0x01};
  lcd_qspi_write_cmd_para(0x0F,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x20,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x21,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x22,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x23,data,sizeof(data));
}
{
  uint8_t data[]={0x04};
  lcd_qspi_write_cmd_para(0x24,data,sizeof(data));
}
{
  uint8_t data[]={0x08};
  lcd_qspi_write_cmd_para(0x25,data,sizeof(data));
}
{
  uint8_t data[]={0x16};
  lcd_qspi_write_cmd_para(0x26,data,sizeof(data));
}
{
  uint8_t data[]={0x17};
  lcd_qspi_write_cmd_para(0x27,data,sizeof(data));
}
{
  uint8_t data[]={0x18};
  lcd_qspi_write_cmd_para(0x28,data,sizeof(data));
}
{
  uint8_t data[]={0x19};
  lcd_qspi_write_cmd_para(0x29,data,sizeof(data));
}
{
  uint8_t data[]={0x33};
  lcd_qspi_write_cmd_para(0x2A,data,sizeof(data));
}
{
  uint8_t data[]={0x32};
  lcd_qspi_write_cmd_para(0x2B,data,sizeof(data));
}
{
  uint8_t data[]={0x34};
  lcd_qspi_write_cmd_para(0x2C,data,sizeof(data));
}
{
  uint8_t data[]={0x35};
  lcd_qspi_write_cmd_para(0x2D,data,sizeof(data));
}
{
  uint8_t data[]={0x01};
  lcd_qspi_write_cmd_para(0x2E,data,sizeof(data));
}
{
  uint8_t data[]={0x01};
  lcd_qspi_write_cmd_para(0x2F,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0x12};
  lcd_qspi_write_cmd_para(0xFF,data,sizeof(data));
}
{
  uint8_t data[]={0x99};
  lcd_qspi_write_cmd_para(0x00,data,sizeof(data));
}
{
  uint8_t data[]={0x28};
  lcd_qspi_write_cmd_para(0x2A,data,sizeof(data));
}
{
  uint8_t data[]={0x0f};
  lcd_qspi_write_cmd_para(0x2B,data,sizeof(data));
}
{
  uint8_t data[]={0x16};
  lcd_qspi_write_cmd_para(0x2C,data,sizeof(data));
}
{
  uint8_t data[]={0x28};
  lcd_qspi_write_cmd_para(0x2D,data,sizeof(data));
}
{
  uint8_t data[]={0x0f};
  lcd_qspi_write_cmd_para(0x2E,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0xA0};
  lcd_qspi_write_cmd_para(0xFF,data,sizeof(data));
}
{
  uint8_t data[]={0xdc};
  lcd_qspi_write_cmd_para(0x08,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0x45};
  lcd_qspi_write_cmd_para(0xFF,data,sizeof(data));
}
{
  uint8_t data[]={0x64};
  lcd_qspi_write_cmd_para(0x03,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0x42};
  lcd_qspi_write_cmd_para(0xFF,data,sizeof(data));
}
{
  uint8_t data[]={0x2c};
  lcd_qspi_write_cmd_para(0x05,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0x11};
  lcd_qspi_write_cmd_para(0xFF,data,sizeof(data));
}
{
  uint8_t data[]={0x01};
  lcd_qspi_write_cmd_para(0x50,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0x00};
  lcd_qspi_write_cmd_para(0xFF,data,sizeof(data));
}
{
  uint8_t data[]={0x00,0x00,0x01,0x63};
  lcd_qspi_write_cmd_para(0x2A,data,sizeof(data));
}
{
  uint8_t data[]={0x00,0x00,0x01,0x8F};
  lcd_qspi_write_cmd_para(0x2B,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0x40};
  lcd_qspi_write_cmd_para(0xFF,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x86,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0x00};
  lcd_qspi_write_cmd_para(0xFF,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0x12};
  lcd_qspi_write_cmd_para(0xFF,data,sizeof(data));
}
{
  uint8_t data[]={0x66};
  lcd_qspi_write_cmd_para(0x0D,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0x17};
  lcd_qspi_write_cmd_para(0xFF,data,sizeof(data));
}
{
  uint8_t data[]={0x3c};
  lcd_qspi_write_cmd_para(0x39,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0x31};
  lcd_qspi_write_cmd_para(0xff,data,sizeof(data));
}
{
  uint8_t data[]={0x03};
  lcd_qspi_write_cmd_para(0x38,data,sizeof(data));
}
{
  uint8_t data[]={0xf0};
  lcd_qspi_write_cmd_para(0x39,data,sizeof(data));
}
{
  uint8_t data[]={0x03};
  lcd_qspi_write_cmd_para(0x36,data,sizeof(data));
}
{
  uint8_t data[]={0xe8};
  lcd_qspi_write_cmd_para(0x37,data,sizeof(data));
}
{
  uint8_t data[]={0x03};
  lcd_qspi_write_cmd_para(0x34,data,sizeof(data));
}
{
  uint8_t data[]={0xCF};
  lcd_qspi_write_cmd_para(0x35,data,sizeof(data));
}
{
  uint8_t data[]={0x03};
  lcd_qspi_write_cmd_para(0x32,data,sizeof(data));
}
{
  uint8_t data[]={0xBA};
  lcd_qspi_write_cmd_para(0x33,data,sizeof(data));
}
{
  uint8_t data[]={0x03};
  lcd_qspi_write_cmd_para(0x30,data,sizeof(data));
}
{
  uint8_t data[]={0xA2};
  lcd_qspi_write_cmd_para(0x31,data,sizeof(data));
}
{
  uint8_t data[]={0x03};
  lcd_qspi_write_cmd_para(0x2e,data,sizeof(data));
}
{
  uint8_t data[]={0x8E};
  lcd_qspi_write_cmd_para(0x2f,data,sizeof(data));
}
{
  uint8_t data[]={0x03};
  lcd_qspi_write_cmd_para(0x2c,data,sizeof(data));
}
{
  uint8_t data[]={0x70};
  lcd_qspi_write_cmd_para(0x2d,data,sizeof(data));
}
{
  uint8_t data[]={0x03};
  lcd_qspi_write_cmd_para(0x2a,data,sizeof(data));
}
{
  uint8_t data[]={0x52};
  lcd_qspi_write_cmd_para(0x2b,data,sizeof(data));
}
{
  uint8_t data[]={0x03};
  lcd_qspi_write_cmd_para(0x28,data,sizeof(data));
}
{
  uint8_t data[]={0x3E};
  lcd_qspi_write_cmd_para(0x29,data,sizeof(data));
}
{
  uint8_t data[]={0x02};
  lcd_qspi_write_cmd_para(0x26,data,sizeof(data));
}
{
  uint8_t data[]={0xfa};
  lcd_qspi_write_cmd_para(0x27,data,sizeof(data));
}
{
  uint8_t data[]={0x02};
  lcd_qspi_write_cmd_para(0x24,data,sizeof(data));
}
{
  uint8_t data[]={0xc2};
  lcd_qspi_write_cmd_para(0x25,data,sizeof(data));
}
{
  uint8_t data[]={0x02};
  lcd_qspi_write_cmd_para(0x22,data,sizeof(data));
}
{
  uint8_t data[]={0x80};
  lcd_qspi_write_cmd_para(0x23,data,sizeof(data));
}
{
  uint8_t data[]={0x02};
  lcd_qspi_write_cmd_para(0x20,data,sizeof(data));
}
{
  uint8_t data[]={0x53};
  lcd_qspi_write_cmd_para(0x21,data,sizeof(data));
}
{
  uint8_t data[]={0x02};
  lcd_qspi_write_cmd_para(0x1e,data,sizeof(data));
}
{
  uint8_t data[]={0x0e};
  lcd_qspi_write_cmd_para(0x1f,data,sizeof(data));
}
{
  uint8_t data[]={0x01};
  lcd_qspi_write_cmd_para(0x1c,data,sizeof(data));
}
{
  uint8_t data[]={0xcf};
  lcd_qspi_write_cmd_para(0x1d,data,sizeof(data));
}
{
  uint8_t data[]={0x01};
  lcd_qspi_write_cmd_para(0x1a,data,sizeof(data));
}
{
  uint8_t data[]={0x7b};
  lcd_qspi_write_cmd_para(0x1b,data,sizeof(data));
}
{
  uint8_t data[]={0x01};
  lcd_qspi_write_cmd_para(0x18,data,sizeof(data));
}
{
  uint8_t data[]={0x3d};
  lcd_qspi_write_cmd_para(0x19,data,sizeof(data));
}
{
  uint8_t data[]={0x01};
  lcd_qspi_write_cmd_para(0x16,data,sizeof(data));
}
{
  uint8_t data[]={0x0e};
  lcd_qspi_write_cmd_para(0x17,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x14,data,sizeof(data));
}
{
  uint8_t data[]={0xd0};
  lcd_qspi_write_cmd_para(0x15,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x12,data,sizeof(data));
}
{
  uint8_t data[]={0xa6};
  lcd_qspi_write_cmd_para(0x13,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x10,data,sizeof(data));
}
{
  uint8_t data[]={0x79};
  lcd_qspi_write_cmd_para(0x11,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x0e,data,sizeof(data));
}
{
  uint8_t data[]={0x72};
  lcd_qspi_write_cmd_para(0x0f,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x0c,data,sizeof(data));
}
{
  uint8_t data[]={0x62};
  lcd_qspi_write_cmd_para(0x0d,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x0a,data,sizeof(data));
}
{
  uint8_t data[]={0x54};
  lcd_qspi_write_cmd_para(0x0b,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x08,data,sizeof(data));
}
{
  uint8_t data[]={0x3d};
  lcd_qspi_write_cmd_para(0x09,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x06,data,sizeof(data));
}
{
  uint8_t data[]={0x36};
  lcd_qspi_write_cmd_para(0x07,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x04,data,sizeof(data));
}
{
  uint8_t data[]={0x1c};
  lcd_qspi_write_cmd_para(0x05,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x02,data,sizeof(data));
}
{
  uint8_t data[]={0x09};
  lcd_qspi_write_cmd_para(0x03,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0x00};
  lcd_qspi_write_cmd_para(0xff,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0x32};
  lcd_qspi_write_cmd_para(0xff,data,sizeof(data));
}
{
  uint8_t data[]={0x03};
  lcd_qspi_write_cmd_para(0x38,data,sizeof(data));
}
{
  uint8_t data[]={0xf0};
  lcd_qspi_write_cmd_para(0x39,data,sizeof(data));
}
{
  uint8_t data[]={0x03};
  lcd_qspi_write_cmd_para(0x36,data,sizeof(data));
}
{
  uint8_t data[]={0xe8};
  lcd_qspi_write_cmd_para(0x37,data,sizeof(data));
}
{
  uint8_t data[]={0x03};
  lcd_qspi_write_cmd_para(0x34,data,sizeof(data));
}
{
  uint8_t data[]={0xCF};
  lcd_qspi_write_cmd_para(0x35,data,sizeof(data));
}
{
  uint8_t data[]={0x03};
  lcd_qspi_write_cmd_para(0x32,data,sizeof(data));
}
{
  uint8_t data[]={0xBA};
  lcd_qspi_write_cmd_para(0x33,data,sizeof(data));
}
{
  uint8_t data[]={0x03};
  lcd_qspi_write_cmd_para(0x30,data,sizeof(data));
}
{
  uint8_t data[]={0xA2};
  lcd_qspi_write_cmd_para(0x31,data,sizeof(data));
}
{
  uint8_t data[]={0x03};
  lcd_qspi_write_cmd_para(0x2e,data,sizeof(data));
}
{
  uint8_t data[]={0x8E};
  lcd_qspi_write_cmd_para(0x2f,data,sizeof(data));
}
{
  uint8_t data[]={0x03};
  lcd_qspi_write_cmd_para(0x2c,data,sizeof(data));
}
{
  uint8_t data[]={0x70};
  lcd_qspi_write_cmd_para(0x2d,data,sizeof(data));
}
{
  uint8_t data[]={0x03};
  lcd_qspi_write_cmd_para(0x2a,data,sizeof(data));
}
{
  uint8_t data[]={0x52};
  lcd_qspi_write_cmd_para(0x2b,data,sizeof(data));
}
{
  uint8_t data[]={0x03};
  lcd_qspi_write_cmd_para(0x28,data,sizeof(data));
}
{
  uint8_t data[]={0x3E};
  lcd_qspi_write_cmd_para(0x29,data,sizeof(data));
}
{
  uint8_t data[]={0x02};
  lcd_qspi_write_cmd_para(0x26,data,sizeof(data));
}
{
  uint8_t data[]={0xfa};
  lcd_qspi_write_cmd_para(0x27,data,sizeof(data));
}
{
  uint8_t data[]={0x02};
  lcd_qspi_write_cmd_para(0x24,data,sizeof(data));
}
{
  uint8_t data[]={0xc2};
  lcd_qspi_write_cmd_para(0x25,data,sizeof(data));
}
{
  uint8_t data[]={0x02};
  lcd_qspi_write_cmd_para(0x22,data,sizeof(data));
}
{
  uint8_t data[]={0x80};
  lcd_qspi_write_cmd_para(0x23,data,sizeof(data));
}
{
  uint8_t data[]={0x02};
  lcd_qspi_write_cmd_para(0x20,data,sizeof(data));
}
{
  uint8_t data[]={0x53};
  lcd_qspi_write_cmd_para(0x21,data,sizeof(data));
}
{
  uint8_t data[]={0x02};
  lcd_qspi_write_cmd_para(0x1e,data,sizeof(data));
}
{
  uint8_t data[]={0x0e};
  lcd_qspi_write_cmd_para(0x1f,data,sizeof(data));
}
{
  uint8_t data[]={0x01};
  lcd_qspi_write_cmd_para(0x1c,data,sizeof(data));
}
{
  uint8_t data[]={0xcf};
  lcd_qspi_write_cmd_para(0x1d,data,sizeof(data));
}
{
  uint8_t data[]={0x01};
  lcd_qspi_write_cmd_para(0x1a,data,sizeof(data));
}
{
  uint8_t data[]={0x7b};
  lcd_qspi_write_cmd_para(0x1b,data,sizeof(data));
}
{
  uint8_t data[]={0x01};
  lcd_qspi_write_cmd_para(0x18,data,sizeof(data));
}
{
  uint8_t data[]={0x3d};
  lcd_qspi_write_cmd_para(0x19,data,sizeof(data));
}
{
  uint8_t data[]={0x01};
  lcd_qspi_write_cmd_para(0x16,data,sizeof(data));
}
{
  uint8_t data[]={0x0e};
  lcd_qspi_write_cmd_para(0x17,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x14,data,sizeof(data));
}
{
  uint8_t data[]={0xd0};
  lcd_qspi_write_cmd_para(0x15,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x12,data,sizeof(data));
}
{
  uint8_t data[]={0xa6};
  lcd_qspi_write_cmd_para(0x13,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x10,data,sizeof(data));
}
{
  uint8_t data[]={0x79};
  lcd_qspi_write_cmd_para(0x11,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x0e,data,sizeof(data));
}
{
  uint8_t data[]={0x72};
  lcd_qspi_write_cmd_para(0x0f,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x0c,data,sizeof(data));
}
{
  uint8_t data[]={0x62};
  lcd_qspi_write_cmd_para(0x0d,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x0a,data,sizeof(data));
}
{
  uint8_t data[]={0x54};
  lcd_qspi_write_cmd_para(0x0b,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x08,data,sizeof(data));
}
{
  uint8_t data[]={0x3d};
  lcd_qspi_write_cmd_para(0x09,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x06,data,sizeof(data));
}
{
  uint8_t data[]={0x36};
  lcd_qspi_write_cmd_para(0x07,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x04,data,sizeof(data));
}
{
  uint8_t data[]={0x1c};
  lcd_qspi_write_cmd_para(0x05,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x02,data,sizeof(data));
}
{
  uint8_t data[]={0x09};
  lcd_qspi_write_cmd_para(0x03,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0x00};
  lcd_qspi_write_cmd_para(0xff,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0x11};
  lcd_qspi_write_cmd_para(0xFF,data,sizeof(data));
}
{
  uint8_t data[]={0x01};
  lcd_qspi_write_cmd_para(0x60,data,sizeof(data));
}
{
  uint8_t data[]={0x03};
  lcd_qspi_write_cmd_para(0x65,data,sizeof(data));
}
{
  uint8_t data[]={0x38};
  lcd_qspi_write_cmd_para(0x66,data,sizeof(data));
}
{
  uint8_t data[]={0x04};
  lcd_qspi_write_cmd_para(0x67,data,sizeof(data));
}
{
  uint8_t data[]={0x34};
  lcd_qspi_write_cmd_para(0x68,data,sizeof(data));
}
{
  uint8_t data[]={0x03};
  lcd_qspi_write_cmd_para(0x69,data,sizeof(data));
}
{
  uint8_t data[]={0x03};
  lcd_qspi_write_cmd_para(0x61,data,sizeof(data));
}
{
  uint8_t data[]={0x38};
  lcd_qspi_write_cmd_para(0x62,data,sizeof(data));
}
{
  uint8_t data[]={0x04};
  lcd_qspi_write_cmd_para(0x63,data,sizeof(data));
}
{
  uint8_t data[]={0x34};
  lcd_qspi_write_cmd_para(0x64,data,sizeof(data));
}
{
  uint8_t data[]={0x11};
  lcd_qspi_write_cmd_para(0x0A,data,sizeof(data));
}
{
  uint8_t data[]={0x14};
  lcd_qspi_write_cmd_para(0x0B,data,sizeof(data));
}
{
  uint8_t data[]={0x14};
  lcd_qspi_write_cmd_para(0x0c,data,sizeof(data));
}
{
  uint8_t data[]={0x06};
  lcd_qspi_write_cmd_para(0x55,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0x42};
  lcd_qspi_write_cmd_para(0xFF,data,sizeof(data));
}
{
  uint8_t data[]={0x3D};
  lcd_qspi_write_cmd_para(0x05,data,sizeof(data));
}
{
  uint8_t data[]={0x03};
  lcd_qspi_write_cmd_para(0x06,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0x00};
  lcd_qspi_write_cmd_para(0xFF,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0x12};
  lcd_qspi_write_cmd_para(0xFF,data,sizeof(data));
}
{
  uint8_t data[]={0xDC};
  lcd_qspi_write_cmd_para(0x1F,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0x17};
  lcd_qspi_write_cmd_para(0xff,data,sizeof(data));
}
{
  uint8_t data[]={0xAA};
  lcd_qspi_write_cmd_para(0x11,data,sizeof(data));
}
{
  uint8_t data[]={0x12};
  lcd_qspi_write_cmd_para(0x16,data,sizeof(data));
}
{
  uint8_t data[]={0xC3};
  lcd_qspi_write_cmd_para(0x0B,data,sizeof(data));
}
{
  uint8_t data[]={0x0E};
  lcd_qspi_write_cmd_para(0x10,data,sizeof(data));
}
{
  uint8_t data[]={0xAA};
  lcd_qspi_write_cmd_para(0x14,data,sizeof(data));
}
{
  uint8_t data[]={0xA0};
  lcd_qspi_write_cmd_para(0x18,data,sizeof(data));
}
{
  uint8_t data[]={0x80};
  lcd_qspi_write_cmd_para(0x1A,data,sizeof(data));
}
{
  uint8_t data[]={0x80};
  lcd_qspi_write_cmd_para(0x1F,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0x11};
  lcd_qspi_write_cmd_para(0xff,data,sizeof(data));
}
{
  uint8_t data[]={0xEE};
  lcd_qspi_write_cmd_para(0x30,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0x12};
  lcd_qspi_write_cmd_para(0xff,data,sizeof(data));
}
{
  uint8_t data[]={0x0F};
  lcd_qspi_write_cmd_para(0x15,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0x2D};
  lcd_qspi_write_cmd_para(0xff,data,sizeof(data));
}
{
  uint8_t data[]={0x3E};
  lcd_qspi_write_cmd_para(0x01,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0x40};
  lcd_qspi_write_cmd_para(0xff,data,sizeof(data));
}
{
  uint8_t data[]={0xC4};
  lcd_qspi_write_cmd_para(0x83,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0x12};
  lcd_qspi_write_cmd_para(0xFF,data,sizeof(data));
}
{
  uint8_t data[]={0x1e};
  lcd_qspi_write_cmd_para(0x2B,data,sizeof(data));
}
{
  uint8_t data[]={0x26};
  lcd_qspi_write_cmd_para(0x2C,data,sizeof(data));
}
{
  uint8_t data[]={0x1e};
  lcd_qspi_write_cmd_para(0x2E,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0x12};
  lcd_qspi_write_cmd_para(0xFF,data,sizeof(data));
}
{
  uint8_t data[]={0x0F};
  lcd_qspi_write_cmd_para(0x10,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0x18};
  lcd_qspi_write_cmd_para(0xFF,data,sizeof(data));
}
{
  uint8_t data[]={0x01};
  lcd_qspi_write_cmd_para(0x01,data,sizeof(data));
}
{
  uint8_t data[]={0x1E};
  lcd_qspi_write_cmd_para(0x00,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0x43};
  lcd_qspi_write_cmd_para(0xFF,data,sizeof(data));
}
{
  uint8_t data[]={0x04};
  lcd_qspi_write_cmd_para(0x03,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0x50};
  lcd_qspi_write_cmd_para(0xFF,data,sizeof(data));
}
{
  uint8_t data[]={0x08};
  lcd_qspi_write_cmd_para(0x05,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0x00};
  lcd_qspi_write_cmd_para(0xFF,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0x50};
  lcd_qspi_write_cmd_para(0xFF,data,sizeof(data));
}
{
  uint8_t data[]={0xA6};
  lcd_qspi_write_cmd_para(0x00,data,sizeof(data));
}
{
  uint8_t data[]={0xA6};
  lcd_qspi_write_cmd_para(0x01,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0x00};
  lcd_qspi_write_cmd_para(0xFF,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0x50};
  lcd_qspi_write_cmd_para(0xFF,data,sizeof(data));
}
{
  uint8_t data[]={0x55};
  lcd_qspi_write_cmd_para(0x08,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0x00};
  lcd_qspi_write_cmd_para(0xFF,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0x10};
  lcd_qspi_write_cmd_para(0xFF,data,sizeof(data));
}
{
  uint8_t data[]={0x43};
  lcd_qspi_write_cmd_para(0x0B,data,sizeof(data));
}
{
  uint8_t data[]={0x12};
  lcd_qspi_write_cmd_para(0x0C,data,sizeof(data));
}
{
  uint8_t data[]={0x01};
  lcd_qspi_write_cmd_para(0x10,data,sizeof(data));
}
{
  uint8_t data[]={0x12};
  lcd_qspi_write_cmd_para(0x11,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x15,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x16,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x1A,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x1B,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x61,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x62,data,sizeof(data));
}
{
  uint8_t data[]={0x11};
  lcd_qspi_write_cmd_para(0x51,data,sizeof(data));
}
{
  uint8_t data[]={0x55};
  lcd_qspi_write_cmd_para(0x55,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x58,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x5C,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0x10};
  lcd_qspi_write_cmd_para(0xFF,data,sizeof(data));
}
{
  uint8_t data[]={0x81};
  lcd_qspi_write_cmd_para(0x20,data,sizeof(data));
}
{
  uint8_t data[]={0x82};
  lcd_qspi_write_cmd_para(0x21,data,sizeof(data));
}
{
  uint8_t data[]={0x72};
  lcd_qspi_write_cmd_para(0x22,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x30,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x31,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x32,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0x10};
  lcd_qspi_write_cmd_para(0xFF,data,sizeof(data));
}
{
  uint8_t data[]={0x44};
  lcd_qspi_write_cmd_para(0x44,data,sizeof(data));
}
{
  uint8_t data[]={0x55};
  lcd_qspi_write_cmd_para(0x45,data,sizeof(data));
}
{
  uint8_t data[]={0x66};
  lcd_qspi_write_cmd_para(0x46,data,sizeof(data));
}
{
  uint8_t data[]={0x77};
  lcd_qspi_write_cmd_para(0x47,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x49,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x4A,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x4B,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0x17};
  lcd_qspi_write_cmd_para(0xFF,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x37,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0x15};
  lcd_qspi_write_cmd_para(0xFF,data,sizeof(data));
}
{
  uint8_t data[]={0x08};
  lcd_qspi_write_cmd_para(0x04,data,sizeof(data));
}
{
  uint8_t data[]={0x04};
  lcd_qspi_write_cmd_para(0x05,data,sizeof(data));
}
{
  uint8_t data[]={0x1C};
  lcd_qspi_write_cmd_para(0x06,data,sizeof(data));
}
{
  uint8_t data[]={0x1A};
  lcd_qspi_write_cmd_para(0x07,data,sizeof(data));
}
{
  uint8_t data[]={0x18};
  lcd_qspi_write_cmd_para(0x08,data,sizeof(data));
}
{
  uint8_t data[]={0x16};
  lcd_qspi_write_cmd_para(0x09,data,sizeof(data));
}
{
  uint8_t data[]={0x05};
  lcd_qspi_write_cmd_para(0x24,data,sizeof(data));
}
{
  uint8_t data[]={0x09};
  lcd_qspi_write_cmd_para(0x25,data,sizeof(data));
}
{
  uint8_t data[]={0x17};
  lcd_qspi_write_cmd_para(0x26,data,sizeof(data));
}
{
  uint8_t data[]={0x19};
  lcd_qspi_write_cmd_para(0x27,data,sizeof(data));
}
{
  uint8_t data[]={0x1B};
  lcd_qspi_write_cmd_para(0x28,data,sizeof(data));
}
{
  uint8_t data[]={0x1D};
  lcd_qspi_write_cmd_para(0x29,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0x16};
  lcd_qspi_write_cmd_para(0xFF,data,sizeof(data));
}
{
  uint8_t data[]={0x09};
  lcd_qspi_write_cmd_para(0x04,data,sizeof(data));
}
{
  uint8_t data[]={0x05};
  lcd_qspi_write_cmd_para(0x05,data,sizeof(data));
}
{
  uint8_t data[]={0x1D};
  lcd_qspi_write_cmd_para(0x06,data,sizeof(data));
}
{
  uint8_t data[]={0x1B};
  lcd_qspi_write_cmd_para(0x07,data,sizeof(data));
}
{
  uint8_t data[]={0x19};
  lcd_qspi_write_cmd_para(0x08,data,sizeof(data));
}
{
  uint8_t data[]={0x17};
  lcd_qspi_write_cmd_para(0x09,data,sizeof(data));
}
{
  uint8_t data[]={0x04};
  lcd_qspi_write_cmd_para(0x24,data,sizeof(data));
}
{
  uint8_t data[]={0x08};
  lcd_qspi_write_cmd_para(0x25,data,sizeof(data));
}
{
  uint8_t data[]={0x16};
  lcd_qspi_write_cmd_para(0x26,data,sizeof(data));
}
{
  uint8_t data[]={0x18};
  lcd_qspi_write_cmd_para(0x27,data,sizeof(data));
}
{
  uint8_t data[]={0x1A};
  lcd_qspi_write_cmd_para(0x28,data,sizeof(data));
}
{
  uint8_t data[]={0x1C};
  lcd_qspi_write_cmd_para(0x29,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0x18};
  lcd_qspi_write_cmd_para(0xFF,data,sizeof(data));
}
{
  uint8_t data[]={0x02,};
  lcd_qspi_write_cmd_para(0x1F,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0x18};
  lcd_qspi_write_cmd_para(0xFF,data,sizeof(data));
}
{
  uint8_t data[]={0x01};
  lcd_qspi_write_cmd_para(0x3A,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0x11	};
  lcd_qspi_write_cmd_para(0xFF,data,sizeof(data));
}
{
  uint8_t data[]={0x99};
  lcd_qspi_write_cmd_para(0x15,data,sizeof(data));
}
{
  uint8_t data[]={0x99};
  lcd_qspi_write_cmd_para(0x16,data,sizeof(data));
}
{
  uint8_t data[]={0x88	};
  lcd_qspi_write_cmd_para(0x1C,data,sizeof(data));
}
{
  uint8_t data[]={0x88};
  lcd_qspi_write_cmd_para(0x1D,data,sizeof(data));
}
{
  uint8_t data[]={0x88};
  lcd_qspi_write_cmd_para(0x1E,data,sizeof(data));
}
{
  uint8_t data[]={0xf0};
  lcd_qspi_write_cmd_para(0x13,data,sizeof(data));
}
{
  uint8_t data[]={0x34};
  lcd_qspi_write_cmd_para(0x14,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0x12};
  lcd_qspi_write_cmd_para(0xFF,data,sizeof(data));
}
{
  uint8_t data[]={0x06};
  lcd_qspi_write_cmd_para(0x06,data,sizeof(data));
}
{
  uint8_t data[]={0x89};
  lcd_qspi_write_cmd_para(0x12,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x18,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0x11};
  lcd_qspi_write_cmd_para(0xFF,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x0A,data,sizeof(data));
}
{
  uint8_t data[]={0xf2};
  lcd_qspi_write_cmd_para(0x0B,data,sizeof(data));
}
{
  uint8_t data[]={0xf2};
  lcd_qspi_write_cmd_para(0x0c,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0x00};
  lcd_qspi_write_cmd_para(0xFF,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0x11};
  lcd_qspi_write_cmd_para(0xFF,data,sizeof(data));
}
{
  uint8_t data[]={0x70};
  lcd_qspi_write_cmd_para(0x08,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x09,data,sizeof(data));
}
{
  uint8_t data[]={0x10};
  lcd_qspi_write_cmd_para(0x6A,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0x2D};
  lcd_qspi_write_cmd_para(0xFF,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x02,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0x00};
  lcd_qspi_write_cmd_para(0xFF,data,sizeof(data));
}
{
  uint8_t data[]={0x00};
  lcd_qspi_write_cmd_para(0x35,data,sizeof(data));
}
{
  uint8_t data[]={0x05};
  lcd_qspi_write_cmd_para(0x3A,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0x12};
  lcd_qspi_write_cmd_para(0xFF,data,sizeof(data));
}
{
  uint8_t data[]={0xC8};
  lcd_qspi_write_cmd_para(0x21,data,sizeof(data));
}
{
  uint8_t data[]={0x20,0x10,0x00};
  lcd_qspi_write_cmd_para(0xFF,data,sizeof(data));
}
{
  lcd_qspi_write_cmd_para( 0x11 , NULL, 0 );
}
LCD_DELAY_MS( 100 );
{
  lcd_qspi_write_cmd_para( 0x29 , NULL, 0 );
}
LCD_DELAY_MS( 100 );

}

#define BIT_RFNE                                (0x00000001 << 3)
#define BIT_ADDR_PHASE_LENGTH(x)                ((x) & 0x00000003)
#define BIT_RD_DUMMY_LENGTH(x)                  (((x) & 0x00000fff))

bool em_lcd_qspi_read(uint16_t addr, uint16_t data_len, uint8_t *data)
{
    uint32_t rd_num = 0;
    SPIC2->ssienr = DISABLE;

    //set addr channel and data channel in ctrl0 register.
    SPIC2->ctrlr0 &= ~(BIT_CMD_CH(3) | BIT_ADDR_CH(3) | BIT_DATA_CH(3));

    //set RX mode in ctrl0 register in user mode.
    SPIC2->ctrlr0 |= BIT_TMOD(3);
    //spic_set_ctrl1(data_len);
    SPIC2->ctrlr1 = data_len;

    SPIC2->addr_length = BIT_ADDR_PHASE_LENGTH(3);
    //set dummy_cycle in autolen register[11:0]
    HAL_UPDATE32(&SPIC2->auto_length, 0xfff, BIT_RD_DUMMY_LENGTH(2));

    addr = addr << 8;
    SPIC2->dr[0].word = 0x03 | __REV(addr);

    SPIC2->ssienr = ENABLE;

    while (rd_num < data_len)
    {
        if (SPIC2->sr & BIT_RFNE)
        {
            data[rd_num++] = SPIC2->dr[0].byte;
        }
    }

    SPIC2->ssienr = DISABLE;

    return true;
}

void em_lcd_qspi_read_test(void)
{
    //Pad_Config(P4_3, PAD_SW_MODE, PAD_IS_PWRON, PAD_PULL_DOWN, PAD_OUT_ENABLE, PAD_OUT_LOW);
    //lcd_qspi_cmd_param(0xFE, 0x00);//page switch
//    {
//        uint8_t data[] = {0x00}; 
//        lcd_qspi_write_cmd_para( 0xfe , data, sizeof(data) );
//    }
//    //lcd_qspi_write_cmd(0xF1);
//    {
//        uint8_t data[] = {0x00}; 
//        lcd_qspi_write_cmd_para( 0xf1 , data, sizeof(data) );
//    }
    uint8_t buf[6],bufda[6],bufdb[6],bufdc[6];
    em_lcd_qspi_read(0x04, 4, buf);
    DBG_DIRECT("[QSPI READ] %x - %x", buf[0], buf[1]);
    
    em_lcd_qspi_read(0xda, 2, bufda);
    DBG_DIRECT("[QSPI READ] %x - %x", bufda[0], bufda[1]);
    
    em_lcd_qspi_read(0xdb, 2, bufdb);
    DBG_DIRECT("[QSPI READ] %x - %x", bufdb[0], bufdb[1]);
    
    em_lcd_qspi_read(0xdc, 2, bufdc);
    DBG_DIRECT("[QSPI READ] %x - %x", bufdc[0], bufdc[1]);
    //Pad_Config(P4_3, PAD_PINMUX_MODE, PAD_IS_PWRON, PAD_PULL_UP, PAD_OUT_DISABLE, PAD_OUT_LOW);
    //while (1);
}

void em_lcd_init(void)
{
//    if( !is_initialized )
    {
//        is_initialized = true; 
        lcd_common_init();
        driver_init();
//        em_lcd_qspi_read_test();
//        lcd_qspi_clear(0,0,GUI_LCD_RES_H-1,GUI_LCD_RES_V-1,0x00F8);
    }
}

void em_lcd_power_off(void)
{
    lcd_qspi_write_cmd_para( 0x28 ,NULL,0); // turn off 
    LCD_DELAY_MS( 20 );
    lcd_qspi_write_cmd_para( 0x10 ,NULL,0); // sleep in 
    LCD_DELAY_MS( 20 );
    xDLPS_reset( lcd_dlps_index );
}

//void em_lcd_power_on(void)
//{
//    lcd_gdma_init();
//    lcd_qspi_write_cmd_para( 0x11 ,NULL,0); // sleep out 
//    LCD_DELAY_MS( 120 );
//    lcd_qspi_write_cmd_para( 0x29 ,NULL,0); // turn on 
//    LCD_DELAY_MS( 20 );
//}
void em_lcd_sleep_out(void)
{
    lcd_gdma_init();
    lcd_qspi_write_cmd_para( 0x11 ,NULL,0);
    LCD_DELAY_MS( 120 );
    xDLPS_set( lcd_dlps_index );
}
void em_lcd_turn_on(void)
{
    lcd_qspi_write_cmd_para( 0x29 ,NULL,0);
    LCD_DELAY_MS( 120 );
}
GUI_RAM_CODE
void em_lcd_set_window(int16_t x0, int16_t y0, int16_t w, int16_t h)
{
    uint16_t xstart = x0;
    uint16_t ystart = y0;
    uint16_t xend = xstart + w - 1;
    uint16_t yend = ystart + h - 1;
    uint8_t  data[4];

    data[0] = xstart >> 8;
    data[1] = xstart & 0xff;
    data[2] = xend >> 8;
    data[3] = xend & 0xff;
    lcd_qspi_write_cmd_para(0x2A,data,4);

    data[0] = ystart >> 8;
    data[1] = ystart & 0xff;
    data[2] = yend >> 8;
    data[3] = yend & 0xff;
    lcd_qspi_write_cmd_para(0x2B,data,4);

    lcd_qspi_enter_data_output_mode();
}

GUI_RAM_CODE
void em_lcd_write(uint8_t* p_buffer, uint32_t size)
{   
    if( lcd_wrctl.isbusy )
    {
        return;
    }
    
    lcd_wrctl.isbusy = true; 
    lcd_wrctl.block_write = false;
    lcd_wrctl.pdata = (uint8_t*)p_buffer;
    lcd_wrctl.offset = 0;
    lcd_wrctl.size = size;
    
    uint32_t chunk_remain = size; 
    if( chunk_remain > LCD_XFER_MAX_SIZE )
    {
        chunk_remain = LCD_XFER_MAX_SIZE; 
    }
    lcd_wrctl.offset = chunk_remain;
    LCD_SEND_DATA_ASYNC( lcd_wrctl.pdata, chunk_remain );
}

/*
    p_buffer -> LCD Memory 
    offset   -> next block offset 
    size     -> size of block  
    rows     -> block count 
*/
GUI_RAM_CODE
void em_lcd_write_block( uint8_t* p_buffer, int16_t offset, uint16_t size, int16_t count )
{
    if( lcd_wrctl.isbusy )
    {
        return;
    }
    
    lcd_wrctl.isbusy                = true;
    lcd_wrctl.block_write           = true; 
    lcd_wrctl.pdata                 = (uint8_t*)p_buffer;
    lcd_wrctl.offset                = 0; 
    lcd_wrctl.size                  = size; 
    
    lcd_wrctl.blocks.used           = 0;
    lcd_wrctl.blocks.size           = size;
    lcd_wrctl.blocks.count          = count;
    lcd_wrctl.blocks.offset         = offset;
    
    uint32_t chunk_remain = size; 
    if( chunk_remain > LCD_XFER_MAX_SIZE )
    {
        chunk_remain = LCD_XFER_MAX_SIZE; 
    }
    lcd_wrctl.offset                = chunk_remain; 
    LCD_SEND_DATA_ASYNC( lcd_wrctl.pdata, chunk_remain );
//    LOG_INFO1("[LCD]: block write count = %d", count );
}

void em_lcd_draw_point( int16_t x, int16_t y, uint16_t color )
{
//    em_lcd_set_window(x, y, 1, 1 );
//    LCD_SEND_DATA_ASYNC( (uint8_t*)&color, 2);
}

void em_lcd_wait_transfer_completed(void)
{
    while( lcd_wrctl.isbusy );
}

bool em_lcd_check_transfer_completed(void)
{
    return lcd_wrctl.isbusy; 
}

